from usermanagement import views
from django.core.exceptions import ObjectDoesNotExist

class AcceptRulesMiddleware(object):
    def process_request(self, request):
        try:
            if request.user.is_authenticated() and (not request.user.get_profile().accepted_rules):
                return views.accept_rules(request)
        except ObjectDoesNotExist:
            return views.accept_rules(request)
        return None